/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package mapdbtest;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;
import org.mapdb.Serializer;

/**
 *
 * @author avilja
 */
public class NoteSerializer implements Serializer<Note>, Serializable {

    @Override
    public void serialize(DataOutput out, Note value) throws IOException {
        out.writeInt(value.getId());
        out.writeUTF(value.getHeading());
        out.writeUTF(value.getNote());
    }

    @Override
    public Note deserialize(DataInput in, int available) throws IOException {
        Note note = new Note(in.readInt(), in.readUTF(), in.readUTF());
        return note;
    }

    @Override
    public int fixedSize() {
        return -1;
    }
   
}
